
public class TimeTranslation {
	public float playbackDiff;

	public void run() {

		if (Main.notesArrayPointer>0){
//			playbackDiff=(float) (playbackDiff/1.2);
			int k = Main.notesArrayPointer-1;
			while (Main.notesArray[k][2]<100||Main.notesArray[k][2]>1000&&k-1>0){
				k=k-1;
			}
			
			float lastDiff = Main.notesArray[k][2];
	
				float time=0;
				float bestFit=100;
				float bestFitRatio=1;
				float ratio=playbackDiff/lastDiff;
				for(int i=0;i<CONSTANTS.ratioArray.length;i++){
					for(int j=0;j<CONSTANTS.ratioArray.length;j++){
	
						if (Math.abs(ratio-CONSTANTS.ratioArray[i]/CONSTANTS.ratioArray[j])<bestFit){
							bestFitRatio=CONSTANTS.ratioArray[i]/CONSTANTS.ratioArray[j];
							bestFit=Math.abs(ratio-CONSTANTS.ratioArray[i]/CONSTANTS.ratioArray[j]);
		
						}
					}
				}
				
				time = lastDiff*bestFitRatio;
			if (time<2000){
				Main.improvise.waitTime = (int) time;
			}
			else {
				if (playbackDiff<2000){
					Main.improvise.waitTime = (int) playbackDiff;
				}
				else
				{
					Main.improvise.waitTime=500;
				}
			}
		}
		else{
			Main.improvise.waitTime = (int) playbackDiff;
		}
		if (playbackDiff!=Main.improvise.waitTime){
//			System.out.println("Altered duration!!");
		}
	}
	

}
